using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using AuthService.Domain.Auth;
using AuthService.Domain.Tokens;
using AuthService.Domain.OAuth;
using AuthService.Permissions;
using AuthService.Services;

namespace AuthService.Auth
{
    /// <summary>
    /// 认证服务应用接口
    /// </summary>
    public interface IAuthServiceAppService : IApplicationService
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        Task<LoginResultDto> LoginAsync(LoginRequestDto input);

        /// <summary>
        /// 登出
        /// </summary>
        Task LogoutAsync(LogoutRequestDto input);

        /// <summary>
        /// 刷新令牌
        /// </summary>
        Task<RefreshTokenResultDto> RefreshTokenAsync(RefreshTokenRequestDto input);

        /// <summary>
        /// 验证令牌
        /// </summary>
        Task<TokenValidationResultDto> ValidateTokenAsync(string token);

        /// <summary>
        /// 获取用户上下文
        /// </summary>
        Task<UserContextDto> GetUserContextAsync(string token);

        /// <summary>
        /// 获取认证配置
        /// </summary>
        Task<AuthenticationConfigurationDto> GetAuthenticationConfigurationAsync();

        /// <summary>
        /// 更新认证配置
        /// </summary>
        Task UpdateAuthenticationConfigurationAsync(UpdateAuthenticationConfigurationRequestDto input);

        /// <summary>
        /// 批量操作
        /// </summary>
        Task<BatchOperationResultDto> BatchOperationAsync(BatchOperationRequestDto input);
    }

    /// <summary>
    /// 认证配置DTO
    /// </summary>
    public class AuthenticationConfigurationDto
    {
        public bool EnableTwoFactor { get; set; }
        public bool RequirePasswordChange { get; set; }
        public int SessionTimeout { get; set; }
        public int MaxConcurrentSessions { get; set; }
    }

    /// <summary>
    /// 更新认证配置请求DTO
    /// </summary>
    public class UpdateAuthenticationConfigurationRequestDto
    {
        public bool EnableTwoFactor { get; set; }
        public bool RequirePasswordChange { get; set; }
        public int SessionTimeout { get; set; }
        public int MaxConcurrentSessions { get; set; }
    }

    /// <summary>
    /// 批量操作请求DTO
    /// </summary>
    public class BatchOperationRequestDto
    {
        public string Operation { get; set; } = string.Empty;
        public Dictionary<string, object> Parameters { get; set; } = new();
    }

    /// <summary>
    /// 批量操作结果DTO
    /// </summary>
    public class BatchOperationResultDto
    {
        public bool Success { get; set; }
        public string Message { get; set; } = string.Empty;
        public Dictionary<string, object> Results { get; set; } = new();
    }
}